home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Animation
/
Animation Vol.1 (Profi ROM)(1994).iso
/
pool
/
updates
/
symantec
/
rtlinc.exe
/
PAGE.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-28
|
3KB
|
114 lines
/*_ page.h Mon May 1 1989 Modified by: Walter Bright */
#ifndef __PAGE_H
#define __PAGE_H 1
#if __cplusplus
extern "C" {
#endif
#if __INTSIZE == 4
#define __BF
#else
#define __BF far
#endif
#define __PGOFF sizeof(unsigned short)
#pragma pack(1)
struct Pageheader
{
/* private: */
unsigned short pagesize; /* total size of this page */
unsigned short maxsize; /* max size of a free block in free list */
unsigned short allocp; /* roving pointer for allocator */
unsigned short bassize; /* size of first block (0 so it is never allocated) */
unsigned short baslnk; /* offset of next free block */
};
#pragma pack()
#define PAGEOVERHEAD sizeof(struct Pageheader)
/*****************************************
* Allocate a block of data and clear it.
* Use:
* unsigned page_calloc(void __BF *baseptr,unsigned size);
* Returns:
* offset of allocated data else 0
*/
unsigned __cdecl page_calloc(void __BF *baseptr,unsigned size);
/*****************************************
* Allocate a block of data.
* unsigned page_malloc(void __BF *baseptr,unsigned size);
* Returns:
* offset of allocated data else 0
*/
unsigned __cdecl page_malloc(void __BF *baseptr,unsigned size);
/*****************************************
* Reallocate memory that was allocated by page_malloc() or page_calloc().
* Use:
* unsigned page_realloc(void __BF *baseptr,unsigned p, unsigned nbytes)
* Returns:
* 0 error
* else offset of reallocated memory
*/
unsigned __cdecl page_realloc(void __BF *baseptr,unsigned p, unsigned nbytes);
/*****************************************
* Free memory that was allocated by page_malloc() or page_calloc().
* Use:
* int page_free(void __BF *baseptr,unsigned p);
* Returns:
* 0 success
* -1 error (baseptr is bad, or memory is corrupted)
*/
int __cdecl page_free(void __BF *baseptr,unsigned p);
/*****************************************
* Determine size of largest free block in page.
* unsigned page_maxfree(void __BF *baseptr);
*/
unsigned __cdecl page_maxfree(void __BF *baseptr);
/*****************************************
* Initialize memory allocation system in a page.
* unsigned page_initialize(void __BF *baseptr,unsigned pagesize);
* Returns:
* size of largest allocatable block
*/
unsigned __cdecl page_initialize(void __BF *baseptr,unsigned pagesize);
/*****************************************
* Return number of bytes allocated for chunk of memory that was
* allocated by page_malloc, page_calloc or page_realloc.
*/
/*unsigned __cdecl page_size(void __BF *baseptr,unsigned p);*/
#define page_size(baseptr,p) \
(*(unsigned short __BF *)((char __BF *)(baseptr) + (p) - __PGOFF) - __PGOFF)
/****************************************
* Convert pointer to page and offset into that page into a void * pointer.
*/
/*void __BF * near page_toptr(void __BF *baseptr,unsigned p);*/
#define page_toptr(baseptr,p) (void __BF *)((char __BF *)(baseptr) + (p))
#if __cplusplus
}
#endif
#endif /* __PAGE_H */